using System.Windows;
using System.Windows.Controls;

namespace EMan.GUI.Common
{
  public static class WpfExtensions
  {
    public static Window GetTopParent( this FrameworkElement fwElement )
    {
      var dpParent = fwElement.Parent;
      do
      {
        dpParent = LogicalTreeHelper.GetParent( dpParent );
      } while( dpParent.GetType().BaseType != typeof( Window ) );
      return dpParent as Window;
    }
  }
}